﻿using System;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Collections.Generic;

namespace EnterpriseServices.Service
{
    /// <summary>
    /// MAKE SURE WE HAVE THE SAME DATA IN THE DATABASE !!!!!
    /// </summary>
    public enum GroupType
    {
        /// <summary>
        /// General Group to be used by all users, no restrictions. 
        /// </summary>
        Public = 0,
        /// <summary>
        /// Groups that are restricted for automated system level processes.
        /// </summary>
        System = 1,
        /// <summary>
        /// Groups that represent employee reporting structures.
        /// </summary>
        Employee = 2,
        /// <summary>
        /// Groups that represent department reporting structures. 
        /// </summary>
        Department = 3
    }

    /// <summary>
    /// MAKE SURE WE HAVE THE SAME DATA IN THE DATABASE !!!!!
    /// </summary>
    public enum GroupState
    {
        /// <summary>
        /// 
        /// </summary>
        Normal = 0,
        /// <summary>
        /// 
        /// </summary>
        InExpirationTimespan = 1,
        /// <summary>
        /// 
        /// </summary>
        Expired = 2
    }

    /// <summary>
    /// 
    /// </summary>
    [ServiceContract(Name="GroupService")]
    public interface IGroupManager
    {
        /// <summary>
        /// Creates the parent group.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        /// <param name="groupType">Type of the group.</param>
        [OperationContract]
        [TransactionFlow(TransactionFlowOption.Allowed)]
        void CreateParentGroup(string userName, string group, GroupType groupType);

        /// <summary>
        /// Creates the sub group.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="parentGroup">The parent group.</param>
        /// <param name="group">The group.</param>
        [OperationContract]
        [TransactionFlow(TransactionFlowOption.Allowed)]
        void CreateSubGroup(string userName, string parentGroup, string group);

        /// <summary>
        /// Deletes the group.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        [OperationContract]
        [TransactionFlow(TransactionFlowOption.Allowed)]
        void DeleteGroup(string userName, string group);

        /// <summary>
        /// Gets the groups for user.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <returns></returns>
        [OperationContract]
        string[] GetGroupsForUser(string userName);

        /// <summary>
        /// Gets the owners in group.
        /// </summary>
        /// <param name="group">The group.</param>
        [OperationContract]
        string[] GetOwnersInGroup(string group);

        /// <summary>
        /// Gets the contacts in group.
        /// </summary>
        /// <param name="group">The group.</param>
        [OperationContract]
        string[] GetContactsInGroup(string group);

        /// <summary>
        /// Gets the direct members in group.
        /// </summary>
        /// <param name="group">The group.</param>
        [OperationContract]
        string[] GetDirectMembersInGroup(string group);

        /// <summary>
        /// Gets all eventual members in group.
        /// </summary>
        /// <param name="group">The group.</param>
        [OperationContract]
        string[] GetAllEventualMembersInGroup(string group);

        /// <summary>
        /// Gets the sub groups in group.
        /// </summary>
        /// <param name="group">The group.</param>
        [OperationContract]
        string[] GetSubGroupsInGroup(string group);

        /// <summary>
        /// Adds the contact to group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        [OperationContract]
        [TransactionFlow(TransactionFlowOption.Allowed)]
        void AddContactToGroup(string ownerUserName, string userName, string group);

        /// <summary>
        /// Adds the owner to group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        [OperationContract]
        [TransactionFlow(TransactionFlowOption.Allowed)]
        void AddOwnerToGroup(string ownerUserName, string userName, string group);


        /// <summary>
        /// Adds the direct member to group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        [OperationContract]
        [TransactionFlow(TransactionFlowOption.Allowed)]
        void AddDirectMemberToGroup(string ownerUserName, string userName, string group);

        /// <summary>
        /// Removes the contact from group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        [OperationContract]
        [TransactionFlow(TransactionFlowOption.Allowed)]
        void RemoveContactFromGroup(string ownerUserName, string userName, string group);

        /// <summary>
        /// Removes the owner from group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        [OperationContract]
        [TransactionFlow(TransactionFlowOption.Allowed)]
        void RemoveOwnerFromGroup(string ownerUserName, string userName, string group);

        /// <summary>
        /// Removes the direct member from group.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        [OperationContract]
        [TransactionFlow(TransactionFlowOption.Allowed)]
        void RemoveDirectMemberFromGroup(string ownerUserName, string userName, string group);

        /// <summary>
        /// Removes the user from groups.
        /// </summary>
        /// <param name="ownerUserName">Name of the owner user.</param>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        [OperationContract]
        [TransactionFlow(TransactionFlowOption.Allowed)]
        void RemoveUserFromGroups(string ownerUserName, string userName, string[] group);

        /// <summary>
        /// Determines whether [is group enabled] [the specified group].
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns>
        /// 	<c>true</c> if [is group enabled] [the specified group]; otherwise, <c>false</c>.
        /// </returns>
        [OperationContract]
        bool IsGroupEnabled(string group);

        /// <summary>
        /// Determines whether [the group exists] [the specified group].
        /// </summary>
        /// <param name="group">The group.</param>
        /// <returns>
        /// 	<c>true</c> if [the group exists] [the specified group]; otherwise, <c>false</c>.
        /// </returns>
        [OperationContract]
        bool GroupExists(string group);

        /// <summary>
        /// Determines whether [is user group owner] [the specified user name].
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="group">The group.</param>
        /// <returns>
        /// 	<c>true</c> if [is user group owner] [the specified user name]; otherwise, <c>false</c>.
        /// </returns>
       [OperationContract]
        bool IsUserGroupOwner(string userName, string group);

       /// <summary>
       /// Determines whether [is user group contact] [the specified user name].
       /// </summary>
       /// <param name="userName">Name of the user.</param>
       /// <param name="group">The group.</param>
       /// <returns>
       /// 	<c>true</c> if [is user group contact] [the specified user name]; otherwise, <c>false</c>.
       /// </returns>
       [OperationContract]
       bool IsUserGroupContact(string userName, string group);

       /// <summary>
       /// Determines whether [is user direct member] [the specified user name].
       /// </summary>
       /// <param name="userName">Name of the user.</param>
       /// <param name="group">The group.</param>
       /// <returns>
       /// 	<c>true</c> if [is user direct member] [the specified user name]; otherwise, <c>false</c>.
       /// </returns>
       [OperationContract]
       bool IsUserDirectMember(string userName, string group);

       /// <summary>
       /// Determines whether [is user eventual member] [the specified user name].
       /// </summary>
       /// <param name="userName">Name of the user.</param>
       /// <param name="group">The group.</param>
       /// <returns>
       /// 	<c>true</c> if [is user eventual member] [the specified user name]; otherwise, <c>false</c>.
       /// </returns>
       [OperationContract]
       bool IsUserEventualMember(string userName, string group);

    }
}